////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   CollabRCBot\GeometricMeanTreeNode.h
///
/// @brief  Declares the implementation of CollabRC::Bot::AI::GeometricMeanTreeNode
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once
#include "OperationTreeNode.h"

namespace CollabRC
{
    namespace Bot
    {
        namespace AI
        {
            /**
             * @brief Implementation of an OperationTreeNode that computes
             * a geometric mean.
             *
             * The operation is invalid if either of the branches is less
             * than zero, and will throw a IllegalOperationException if that
             * occurs.
             * @author Matthew P. Del Buono
             * @version $Id$
             */
            class GeometricMeanTreeNode : public OperationTreeNode
            {
            private:
                class Factory : public OperationTreeNodeFactory
                {
                public:
                    inline Factory() { OperationTreeNode::RegisterOperationTreeNodeFactory(this); };
                    ComputationalTreeNode* Instantiate(const ComputationalTreeNode& lhs, const ComputationalTreeNode &rhs) const;
                };

                static Factory factory;
            public:
                GeometricMeanTreeNode(const ComputationalTreeNode& lhs, const ComputationalTreeNode& rhs);
                GeometricMeanTreeNode(const OperationTreeNode& copy);
                virtual ~GeometricMeanTreeNode(void);

                virtual ComputationalTreeNode* Clone() const;
                virtual float PerformOperation(float lhs, float rhs) const;
                virtual void Accept(ComputationalTreeNodeVisitor& visitor);
            };

        }
    }
}
